﻿using B.S.Ingredients.APIRead.Application.Command.Over;
using B.S.Ingredients.Domain;
using B.S.Ingredients.ErrorCode;
using B.S.Ingredients.Infartructrue.Interfaces;
using MediatR;

namespace B.S.Ingredients.APIRead.Application.CommandHandler.OverHandler
{
    public class ProcessingFtCommandHandler : IRequestHandler<ProcessingFtCommand, APIResult<Processing>>
    {
        public ProcessingFtCommandHandler(IBaseRepository<Processing> processingRepository)
        {
            ProcessingRepository = processingRepository;
        }

        public IBaseRepository<Processing> ProcessingRepository { get; }

        public async Task<APIResult<Processing>> Handle(ProcessingFtCommand request, CancellationToken cancellationToken)
        {
            var path = ProcessingRepository.GetAll().FirstOrDefault(a => a.Productuins == request.Productuins);
            return new APIResult<Processing>
            {
                Code = ResultCode.success,
                Mag = "",
                Data = path
            };
        }
    }
}
